package com.efuture.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 * @ClassNAME JdbcCreateTable
 * @Description 使用jdbc创建一个student表
 * @Author zhaoshanshan
 * @Date 2021/9/19 6:32 下午
 * @Version 1.0
 */
public class JdbcCreateTable {

    public static void main(String[] args) {
        Connection coon = null;
        Statement stmt = null;
        try{
            Class.forName("com.mysql.jdbc.Driver");
            coon = DriverManager.getConnection("jdbc:mysql://localhost:3306/db3","root","zhaoss");
            String sql = "create table student(id int,name varchar(20))";
            stmt = coon.createStatement();
            stmt.executeUpdate(sql);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
           try{
               if(null!=coon){
                   coon.close();
               }
               if(null!=stmt){
                   stmt.close();
               }
           }catch (Exception e){
               e.printStackTrace();
           }
        }
    }
}